package com.hmall.cart.controller.inner;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.hmall.cart.domain.dto.CartFormDTO;
import com.hmall.cart.domain.po.Cart;
import com.hmall.cart.domain.vo.CartVO;
import com.hmall.cart.service.ICartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

@Api(tags = "购物车相关接口")
@RestController
@RequestMapping("/inner/carts")
@RequiredArgsConstructor //生成一个构造器，只会对加了final的属性生成有参构造
@Slf4j
public class CartInnerController {


    private final ICartService cartService;

    @ApiOperation("批量删除购物车中商品")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "购物车条目id集合"),
            @ApiImplicitParam(name = "userId", value = "用户id")
    })
    @DeleteMapping
    public void deleteCartItemByIds(@RequestParam("userId") Long userId, @RequestParam("ids") List<Long> ids) {
        cartService.removeByItemIds(userId, ids);
    }
}
